package com.ys.sboot.druid.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.SQLException;

/**
 * <p>@description:</p>
 *
 * @author yangshuang
 * @version 1.0
 * @date 2018/4/26 20:40
 */
@Configuration
public class DruidConfig {
    @Value("${druid.filters}")
    private String filters;

    @Bean
    @ConfigurationProperties(prefix = "druid")
    public DruidDataSource dataSource() throws SQLException {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setFilters(filters);
        return druidDataSource;
    }

}
